package com.cjh.test.controller;

import com.cjh.test.common.Response;
import com.cjh.test.pojo.User;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author ChenJunhong
 * @date 2018/12/07
 * Description:
 */
@RestController
@RequestMapping("/user")
public class UserContoller {

    @RequestMapping("/login")
    public Response login(@RequestBody User user, HttpServletRequest request){
        if (User.check(user)){
            request.getSession().setAttribute("user",user);
            return Response.success("test-token");
        }else{
            return Response.fail();
        }
    }
}
